
<!DOCTYPE html>
<html lang="en-us">
    <include file="Common/Common/head" />  
    <style type="text/css">
        /*分页格式开始*/
        #dt_basic_wrapper div:nth-child(2){ text-align: center;}
        .current{ padding: 10px 10px 10px 10px; border:1px solid #AFAFAF; background-color: #CCCCCC;}
        .num{ padding: 10px 10px 10px 10px; border:1px solid #AFAFAF;}
        .rows{ margin-top: 20px;}
        /*分页格式结束*/
    </style>
    <body class="desktop-detected pace-done smart-style-3">
    <include file="Common/Common/header" />
    <include file="Widget/Common/navigation" />

    <!-- #MAIN PANEL -->
    <div id="main" role="main">

        <!-- RIBBON -->
        <div id="ribbon">

            <!-- breadcrumb -->
            <ol class="breadcrumb">
                <li>{$module_name}</li>

            </ol>
            <!-- end breadcrumb -->

            <!-- You can also add more buttons to the
            ribbon for further usability

            Example below:

            <span class="ribbon-button-alignment pull-right" style="margin-right:25px">
                    <a href="#" id="search" class="btn btn-ribbon hidden-xs" data-title="search"><i class="fa fa-grid"></i> Change Grid</a>
                    <span id="add" class="btn btn-ribbon hidden-xs" data-title="add"><i class="fa fa-plus"></i> Add</span>
                    <button id="search" class="btn btn-ribbon" data-title="search"><i class="fa fa-search"></i> <span class="hidden-mobile">Search</span></button>
            </span> -->

        </div>
        <!-- END RIBBON -->

        <!-- #MAIN CONTENT -->



        <div id="content">
            <div class="row">
                <div class="col-xs-12 col-sm-7 col-md-7 col-lg-4">
                    <h1 class="page-title txt-color-blueDark">

                        <!-- PAGE HEADER -->
                        <i class="fa-fw fa fa-home"></i> 
                        {$first_title}
                        <span>>  
                            {$second_title}
                        </span>
                    </h1>
                </div>

            </div>

            <!-- widget grid -->
            <section id="widget-grid" class="">

                <!-- row -->
                <div class="row">

                    <!-- NEW WIDGET START -->
                    <article class="col-xs-12 col-sm-12 col-md-12 col-lg-12 sortable-grid ui-sortable">
                        <!-- toolbar -->
                        <div id="toolbar" class="btn-group pull-left">
                            <a class="btn btn-default btn-flat" href="{:U('product_add')}"><i class="fa fa-plus fa-fw"></i>添加候选人</a>
                        </div>
                        <div id="toolbar" class="btn-group">
                            <select id="s_topic" class="btn btn-default btn-flat">
                                <option>请选择专题</option>
                                <volist name="res" id="vo">
                                <option value="{$vo.vid}">{$vo.vtitle}</option>
                                </volist>
                            </select>
                        </div>
                        <table id="bootstrapTable" class="table bootstrapTable">
                        </table> 


                    </article>
                    <!-- WIDGET END -->

                </div>

                <!-- end row -->

                <!-- end row -->

            </section>
            <!-- end widget grid -->

        </div>



        <!-- end row -->

        <!-- END #MAIN CONTENT -->

    </div>
    
    <!-- END #MAIN PANEL -->

    <!-- #PAGE FOOTER -->

    <!-- END FOOTER -->
    <include file="Common/Common/footer" />

    <script src="{$resource_path}js/app.config.js"></script>
    <script src="{$resource_path}js/plugin/jquery-touch/jquery.ui.touch-punch.min.js"></script> 
    <script src="{$resource_path}js/smartwidgets/jarvis.widget.min.js"></script>
    <script src="{$resource_path}js/plugin/bootstrap-table/bootstrap-table.min.js"></script>
    <script src="{$resource_path}js/plugin/bootstrap-table/extensions/cookie/bootstrap-table-cookie.min.js"></script>
    <script src="{$resource_path}js/plugin/bootstrap-table/extensions/export/tableExport.min.js"></script>
    <script src="{$resource_path}js/plugin/bootstrap-table/extensions/export/bootstrap-table-export.min.js"></script>
    <script src="{$resource_path}js/plugin/bootstrap-table/locale/bootstrap-table-zh-CN.min.js"></script>
    <script type="text/javascript">
$(document).ready(function(){
    $("#s_topic").bind('change',function(){
        var topic = $('#s_topic option:selected').val();
        //表格数据  文档参考 http://bootstrap-table.wenzhixin.net.cn/documentation/
        sessionStorage.topic = topic;
        window.location.href = window.location.href; 
    });
});
        $(function () {
            $('#bootstrapTable').bootstrapTable({
            
            url: "{:U('products')}?topic="+sessionStorage.topic,
            pagination: true,
            pageList: [10, 20, 50, 100, 'All'],
            pageSize: 10,
            pageNumber: 1,
            search: true,
            sortable: true,
            idField: "id",
            sortOrder: "DESC",
            showRefresh: true,
            showExport: true,
            showColumns: true,
            clickToSelect: true,
            columns: [{
                    field: 'pid',
                    title: '编号',
                    sortable:true
                }, {
                    field: 'vtitle',
                    title: '专题'
                },  {
                    field: 'thumb',
                    title: '图',
                    formatter: function(value, row, index) {
                      if (row.thumb) {
                        return "<img src='"+row.thumb+"' style='height:100px'/>";
                      }
                    }
                }, {
                    field: 'name',
                    title: '姓名'
                }, 
                {
                    field: 'vote_num',
                    title: '参赛编号',
                    sortable:true
                }, {
                    field: 'votes,pid',
                    title: '票数',
                    formatter: function (value, row, index) {
                        var d = '<a class="btn btn-xs btn-primary" target="_blank" href="{:U("vote_records")}?pid=' + row.pid + '" >'+row.votes+'</a> ';
                        return d;
                    },
                    sortable:true
                }, {
                    field: 'ctime',
                    title: '创建时间'
                },{
                    field: 'id,ctime',
                    title: '操作',
                    formatter: function (value, row, index) {
                        var d = '<a class="btn btn-xs btn-default" href="{:U("product_modify")}?pid=' + row.pid + '" title="编辑"><i class="fa fa-pencil"></i></a> ';
                        d += '<a class="btn btn-xs btn-default btn-delete" href="javascript:product_delete('+ row.pid +')" title="删除，慎重操作"><i class="fa fa-trash text-danger"></i></a> ';
                        return d;
                    }
                }

            ]
        });
        });

        // DO NOT REMOVE : GLOBAL FUNCTIONS!

        $(document).ready(function () {

            pageSetUp();



            /* END BASIC */



            // custom toolbar
            $("div.toolbar").html('<div class="text-right"><img src="img/logo.png" alt="SmartAdmin" style="width: 111px; margin-top: 3px; margin-right: 10px;"></div>');
        })
function product_delete(pid){
    var r = confirm('确定要删除该产品?');
    if(r){
        var url = "{:U('product_delete')}";
        var pid = pid;
        var now_url = window.location.href;
        $.ajax({
            type:'get',
            url:url,
            data:{pid:pid},
            dataType:'json',
            success:function(data){
                if(data.err == 0){
                    window.location.href = now_url;
                }
            }
        });
    }else{
        return false;
    }
    
}

    </script>

</html>